<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>新增社区活动</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" style="margin-left: 30%">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>活动类型</label>
                <div class="layui-input-inline">
                    <input type="text" id="atype" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>标题</label>
                <div class="layui-input-inline">
                    <input type="text" id="atitle" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>内容</label>
                <div class="layui-input-inline">
                    <input type="text" id="ainfo" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>参与人数</label>
                <div class="layui-input-inline">
                    <input type="text" id="acount" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="astartTime" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="aendTime" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" id="butt" lay-submit="">增加</button></div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    layui.use(['table', 'jquery','layer'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        var layer=layui.layer;

        $("#butt").click(function () {
            let atype = $("#atype").val();
            let atitle = $("#atitle").val();
            let ainfo = $("#ainfo").val();
            let acount = $("#acount").val();
            let astartTime = $("#astartTime").val();
            let aendTime = $("#aendTime").val();
            let flag = true;
            if (atype==""||atitle == "" || ainfo == ""  || acount == "" ||astartTime==""||aendTime=="") {
                layer.msg('社区活动信息填写完整!', {
                    icon: 2, time: 800
                });
                flag = false;
            }
            if (flag) {
                $.ajax({
                    type:'POST',
                    url: "http://localhost:8080/api/tjsq",
                    data: {
                        "aType": atype,
                        "aTitle": atitle,
                        "aInfo": ainfo,
                        "aCount": acount,
                        "aStartTime": astartTime,
                        "aEndTime": aendTime,
                        "adminId":sessionStorage.getItem("aid")
                    },
                    headers: {
                        token: localStorage.getItem("token")
                    },
                    datatype: "json",
                    success: function (data) {
                        if(data!="") {
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg('增加成功!',{
                                icon:1
                                ,time:1000
                            },function (){
                                parent.layer.close(index);//关闭当前页
                            });
                        }
                    }
                })

            }
        })
    })
</script>